package com.tc.repositories;

import com.tc.config.SpringDataJPAConfig;
import com.tc.pojo.Customer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Auther: tianchao
 * @Date: 2021/12/4 10:36
 * @Description:
 */
@ContextConfiguration(classes = SpringDataJPAConfig.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class CustomerJPQLtest {
    @Autowired
    private CustomerRepository customerRepository;
    @Test
    public void test(){
        Customer customer = customerRepository.findCustomerByCustName("田超u");
        System.out.println(customer);
        Customer customer2 = customerRepository.find2CustomerByCustName("田超u");
        System.out.println(customer2);
    }
    @Test
    public void testUpdateCustomer(){
        customerRepository.updateCustomer("呵呵2", 4L);

    }
    @Test
    public void testDeleteById(){
        System.out.println(customerRepository.deleteCustomer(4L));

    }
    @Test
    public void testInsertCustomerBySelect(){
        System.out.println(customerRepository.insertCustomerBySelect(1L));
    }
    @Test
    public void testFindCustomerByCustNameByNative(){
        System.out.println(customerRepository.findCustomerByCustNameByNative("田超u"));
    }
}
